package com.binvshe.binvshe.mine;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.binvshe.binvshe.R;
import com.pachong.android.baseuicomponent.activity.BaseActivity;

import butterknife.Bind;

public class AboutModoActivity extends BaseActivity {

    @Bind(R.id.mTvVersion)
    TextView mTvVersion;

    public static void start(Context context) {
        Intent starter = new Intent(context, AboutModoActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        enableBackButton();
        setTitle("关于萌都");
        mTvVersion.setText("版本: V" + getVersion());
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.act_about_modo, null);
    }

    public String getVersion() {
        PackageManager packageManager = getPackageManager();
        PackageInfo packInfo = null;
        String version = null;
        try {
            // getPackageName()是你当前类的包名，0代表是获取版本信息
            packInfo = packageManager.getPackageInfo(getPackageName(), 0);
            version = packInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return version;
    }
}
